/**
 * 邮箱发送
 * @param  {Object}  pm 对方信息
*/
const nodemailer = require("nodemailer");
const Transporter = nodemailer.createTransport({
    host: 'smtp.163.com',
    secure: true,
    auth: {
        user: 'xxxxxxxx', // 发送方的邮箱
        pass: 'xxxxxxxxxx' // smtp 的授权码
    }
});

// emymovgefpwfbdjj

function getCode() {
    let verCode = Math.floor((Math.random() * 1000000) + 1);
    if (verCode < 100000) {
        return getCode()
    }
    return verCode
}



// 随机6位数
exports.getSixCode = () => {
    return getCode()
}

exports.sendMailer = (pm) => {
    return new Promise((resolve, reject) => {
        let title = ""
        // 定义transport对象并发送邮件
        Transporter.sendMail({
            from: `xxxx`, // 发送方邮箱的账号
            to: pm.email, // 邮箱接受者的账号
            subject: title,
            html,
        }, (error, info) => {
            if (error) {
                reject(error)
            }
            resolve(info)
        });
    })
}
